package com.smartwebx.ha.dal.realtime.dao;

import java.util.Date;
import java.util.List;

import org.apache.ibatis.annotations.CacheNamespace;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.smartwebx.ha.dal.config.OracleConfigInfo;
import com.smartwebx.ha.dal.inter.water.IZProcessDataOperatDao;
import com.smartwebx.ha.dal.usebean.DateValue;

/**
 * 潮位
 * 
 * @author zhangxi
 * 
 */
@CacheNamespace(size = 2048, readWrite = false, implementation = org.mybatis.caches.ehcache.LoggingEhcache.class)
public interface TideMapper extends IZProcessDataOperatDao {
	String ST_TIDE_R = OracleConfigInfo.REALTIME_NAME + ".ST_TIDE_R";

	/**
	 * 单站小时潮位过程
	 * 
	 * @param stcd
	 * @param startHour
	 * @param endHour
	 * @return
	 */
	@Select("SELECT TM,TDZ val FROM " + ST_TIDE_R
			+ " WHERE STCD=#{stcd} AND TM>=#{startHour} AND TM<#{endHour}")
	public List<DateValue> getSingleStatHourZProcess(
			@Param("stcd") String stcd, @Param("startHour") Date startHour,
			@Param("endHour") Date endHour);

	/**
	 * 开始时间的上一条的有效水位数据
	 * 
	 * @param stcd
	 * @param datePoint
	 * @return
	 */

	@Select("SELECT TDZ val,TM FROM "
			+ ST_TIDE_R
			+ " WHERE STCD=#{stcd} AND TM<#{datePoint} AND ROWNUM=1 ORDER BY TM DESC")
	public DateValue getStartHourBeforeZVal(@Param("stcd") String stcd,
			@Param("datePoint") Date datePoint);

	/**
	 * 获得单站日水位过程（取每日8时数据）
	 * 
	 * @param stcd
	 * @param startDate
	 * @param endDate
	 * @return
	 */
	@Select("SELECT TM,TDZ val FROM "
			+ ST_TIDE_R
			+ " WHERE STCD=#{stcd} AND TM>=#{startDate} AND TM<#{endDate} AND to_char(TM,'HH24')=8")
	public List<DateValue> getSingleStatDayZProcess(@Param("stcd") String stcd,
			@Param("startDate") Date startDate, @Param("endDate") Date endDate);

}
